package com.example.mybaties.testone.domain;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

public class Car implements BeanFactoryAware, BeanNameAware, InitializingBean, DisposableBean {

    private Logger logger = LogManager.getLogger(this.getClass());

    private String brand;

    private String color;

    private int maxSpeed;

    private BeanFactory beanFactory;

    private String beanName;

    public Car() {
        logger.debug("构造函数...........Car().......");
    }


    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        logger.debug("Car.............setBrand()");
        this.brand = brand;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getMaxSpeed() {
        return maxSpeed;
    }

    public void setMaxSpeed(int maxSpeed) {
        this.maxSpeed = maxSpeed;
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        logger.debug("BeanFactoryAware........setBeanFactory().............");
        this.beanFactory = beanFactory;
    }

    @Override
    public void setBeanName(String s) {
        logger.debug("BeanNameAware..........setBeanName()................");
        this.beanName = s;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.debug("InitializingBean.........afterPropertiesSet()............");
    }

    @Override
    public void destroy() throws Exception {
        logger.debug("DisposableBean..........destroy()..............");
    }

    public void myInit() {
        logger.debug("init-method所指定的方法............myInit()");
    }

    public void myDestroy() {
        logger.debug("destroy-method所指定的方法............myDestroy()");
    }

    @Override
    public String toString() {
        return "Car{" +
                "logger=" + logger +
                ", brand='" + brand + '\'' +
                ", color='" + color + '\'' +
                ", maxSpeed=" + maxSpeed +
                ", beanFactory=" + beanFactory +
                ", beanName='" + beanName + '\'' +
                '}';
    }
}
